/**@author mayh,createDate:2006-4-6
 */
package com.manager;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import lingtong.test.TestRead;

import com.zsoft.webmail.http.HttpUtils;

public class RegisterUser {
	public String kaiTong(String number,String pwd) throws Exception {
		String url = "http://www.m10060.com/webmailln/ext_jzst_createnewname001.jsp?username="+number+"&hostname=10060.com&type=1&s2_state=1&user_grade=2&password="+pwd+"&mailspace_size=200000&udiskspace_size=50000&other1=00&other2=";
		System.out.println("url="+url);
		java.net.HttpURLConnection huc = HttpUtils.getConnection(url, null);
		HttpUtils.sendRequest(huc, null);
		String src = HttpUtils.getResponse(huc);
		return src;
	}
	public void Regesiter(){
		try {
			FileReader input = new FileReader("d://register/number.txt");
			BufferedReader br = new BufferedReader(input);
			FileWriter output = new FileWriter("d://register/success.txt");
			BufferedWriter bw = new BufferedWriter(output);
			FileWriter output_error = new FileWriter("d://register/error.txt");
			BufferedWriter bw_error = new BufferedWriter(output_error);
			//Date date = new Date();
			String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			String s = br.readLine();
			
			while (s != null) {
				RegisterUser register = new RegisterUser();
               
				try {
			System.out.println("number="+s+"  "+s.substring(0,s.indexOf(","))+"  "+s.substring(s.indexOf(",")+1,s.length()));
					String ending = register.kaiTong(s.substring(0,s.indexOf(",")),s.substring(s.indexOf(",")+1,s.length()));
					
					bw.write(s);
					bw.newLine();
				} catch (Exception e) {
					bw_error.write(s);
					bw_error.newLine();
					e.printStackTrace();
				}
				s = br.readLine();
			}
			br.close();
			bw_error.close();
			bw.close();
			//Date date1 = new Date();
			String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			System.out.println("createTime= " + startTime);
			System.out.println("finishTime= " + endTime);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

	public static void main(String[] args) {
		RegisterUser register = new RegisterUser();
		register.Regesiter();
		
	}

}
